package com.hqd.ch03.v23.aop.framework.autoproxy;

import com.hqd.ch03.v23.thread.NamedThreadLocal;

public class ProxyCreationContext {
    private static final ThreadLocal<String> currentProxiedBeanName =
            new NamedThreadLocal<>("Name of currently proxied bean");


    private ProxyCreationContext() {
    }

    public static String getCurrentProxiedBeanName() {
        return currentProxiedBeanName.get();
    }

    static void setCurrentProxiedBeanName(String beanName) {
        if (beanName != null) {
            currentProxiedBeanName.set(beanName);
        } else {
            currentProxiedBeanName.remove();
        }
    }
}
